PATHMac OS 8 and 9 Developer Documentation > Interapplication Communication > AppleScript for Scripters >

AppleScript Language Guide

   

Middle Element

The Middle Element reference form specifies the middle object of a particular class in a container. This form is rarely used.

SYNTAX
middle className

where

className is the class identifier for the specified object.

EXAMPLES
tell application "AppleWorks"
    middle paragraph of text body of front document
end tell
middle item of {1, "doughnut", 33} --result: "doughnut"
middle item of {1, "doughnut", 22, 33} --result: "doughnut"
middle item of {1, "doughnut", 11, 22, 33} --result: 11
NOTES

AppleScript calculates the middle object with the expression ((n + 1) div 2) , where n is the number of objects and div is the integer division operator. If there is an even number of objects in the container, the result is rounded down. For example, the middle word of a paragraph containing twenty words is the tenth word.


© 1999 Apple Computer, Inc. – (Last Updated 21 May 99)